import Vue from 'vue'
import App from './App.vue'
import store from './store'
import iView from 'iview';
import 'iview/dist/styles/iview.css';
import axios from 'axios'
import VueAxios from 'vue-axios'
import VueRouter from 'vue-router';
import {routes} from './router.js';

Vue.use(require('vue-moment'));
Vue.use(VueAxios, axios)
Vue.config.productionTip = false
Vue.use(iView);
Vue.use(VueRouter);


axios.interceptors.request.use(function (config) {

  if(store.state.token){
    config.headers.Authorization = `Bearer ${store.state.token}`;
  }
  return config;
}, function (error) {
  // Do something with request error
  return Promise.reject(error);
});


const router = new VueRouter({
  routes: routes
})

new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app')
